﻿//Sam Marshall

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dijkstra
{
    public class Program
    {
        static void Main()
        {
            Graph graph = new Graph();

            //Nodes
            graph.AddNode("A");
            graph.AddNode("B");
            graph.AddNode("C");
            graph.AddNode("D");
            graph.AddNode("E");
            graph.AddNode("F");
            graph.AddNode("G");
            graph.AddNode("H");
            graph.AddNode("I");
            graph.AddNode("J");
            graph.AddNode("Z");

            //Connections
            graph.AddConnection("A", "B");
            graph.AddConnection("A", "C");
            graph.AddConnection("A", "D");
            graph.AddConnection("A", "E");
            graph.AddConnection("B", "C");
            graph.AddConnection("B", "E");
            graph.AddConnection("B", "F");
            graph.AddConnection("C", "D");
            graph.AddConnection("D", "G");
            graph.AddConnection("E", "H");
            graph.AddConnection("F", "C");
            graph.AddConnection("F", "H");
            graph.AddConnection("F", "I");
            graph.AddConnection("G", "F");
            graph.AddConnection("G", "I");
            graph.AddConnection("H", "J");
            graph.AddConnection("I", "J");

            var calculator = new DistanceCalculator();
            var distances = calculator.CalculateDistances(graph, "G");  // Start from "G"

            foreach (var d in distances)
            {
                Console.WriteLine("{0}, {1}", d.Key, d.Value);
            }
          /*  for (int i = 0; i < 10; i++)
            {
                var queue = graph.Nodes.Values.ToList();
                var connections = graph.Nodes.ElementAt(0).Value.Connections.Where(c => queue.Contains(c.Target));
                graph.Nodes.ElementAt(0).Value.path[0] = "g";
                double distance = graph.Nodes.ElementAt(i).Value.DistanceFromStart;
                foreach (var connection in connections)
                {
                    if (connection.Distance < distance)
                    {
                        graph.Nodes.ElementAt(i).Value.path[(int)(graph.Nodes.ElementAt(0).Value.DistanceFromStart - 2)] = connection.Target.Name;
                    }
                }
            } */
            System.Threading.Thread.Sleep(60000);
        }
    }
}
